<script type="text/javascript">
<!--
var CURRENT_LINK;

$(document).ready(function(){
  $(".thumb-up").click(function(){
    var temp=$(this).parent().parent().parent().attr('id').toString().split('-');
    $.ajax({
	  type: 'POST',
	  url: '<?=Router::url(array('controller'=>'links','action'=>'doVote')) ?>',
	  data: { value: 1, id: temp[1] },
	  success: function(data){
	    $("#lnk-"+data.id+" .vote .votelnk").html(data.result);
	    $("#lnk-"+data.id+" .vote .votes a").html(data.votes);
	  },
	  dataType: 'json'  
	});
    
  });

  $(".thumb-down").click(function(){
    
    var temp=$(this).parent().parent().parent().attr('id').toString().split('-');
    CURRENT_LINK=temp[1];
    $.blockUI({ message: $('#report-link'), css: { width: '275px' } });
  });

  $(".dialog-close").click(function(){
    $.unblockUI();
    return false; 
  });
  
  $(".neg-vote").click(function(){
    $("#lnk-"+CURRENT_LINK+" .vote .votelnk").html($(this).html());
    $("#lnk-"+CURRENT_LINK+" .vote div").css('background','#f1f1f1');
    $("#lnk-"+CURRENT_LINK+" .vote div a").css('color','#ccc');
      
    $.ajax({
	  type: 'POST',
	  url: '<?=Router::url(array('controller'=>'links','action'=>'doVote')) ?>',
	  data: { value:$(this).attr('id').toString().substring(4), id: CURRENT_LINK },
	});
       
    $.unblockUI(); 
    return false;
  });
})
//-->
</script>
<?php  $this->Html->script('jquery.blockUI.js',false); ?>


<div id="report-link">
  <span class="dialog-close">[X]</span>
  <span style="color:#EE3322;font-size:170%;">Negative vote.<br />This link is:</span>
  <?
  $negatives=Configure::read('Monky.negative');
  foreach ($negatives as $v=>$name){
  	echo $this->Html->link($name,array(),array('id'=>'neg-'.$v,'class'=>'neg-vote'));
  }
  ?>
  <a class="dialog-close">[X] <?=__('Close',true) ?></a>
</div>


<div class="links index">
	<h2><?php __('Links');?></h2>
	<div id="links-summary">
	  <? foreach ($links as $link) echo $this->element('link',array('link'=>$link)); ?>
	</div>
	<div style="clear:both"></div>
    <?php
    if($numbers=$paginator->numbers()){
    	echo $paginator->prev('« Previous ', null, null, array('class' => 'disabled')).
		 $numbers.
		 $paginator->next(' Next »', null, null, array('class' => 'disabled'));
    }
    ?> 
</div>

<div class="actions">
    <?=$this->element('categories') ?>

	<h3><?php __('Actions'); ?></h3>
	<ul>
		<li><?php echo $this->Html->link(__('New Link', true), array('action' => 'add')); ?></li>
		<li><?php echo $this->Html->link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Blogs', true), array('controller' => 'blogs', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Blog', true), array('controller' => 'blogs', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Categories', true), array('controller' => 'categories', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Category', true), array('controller' => 'categories', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Comments', true), array('controller' => 'comments', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Comment', true), array('controller' => 'comments', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Favorites', true), array('controller' => 'favorites', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Favorite', true), array('controller' => 'favorites', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Tags', true), array('controller' => 'tags', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Tag', true), array('controller' => 'tags', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Trackbacks', true), array('controller' => 'trackbacks', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Trackback', true), array('controller' => 'trackbacks', 'action' => 'add')); ?> </li>
		<li><?php echo $this->Html->link(__('List Votes', true), array('controller' => 'votes', 'action' => 'index')); ?> </li>
		<li><?php echo $this->Html->link(__('New Vote', true), array('controller' => 'votes', 'action' => 'add')); ?> </li>
	</ul>
</div>